package com.whfc.iot.mach.processor;

import com.whfc.common.constant.QueueConst;
import com.whfc.common.util.JSONUtil;
import com.whfc.iot.mach.entity.MachMsg0x0A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description: 0x09消息处理
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/7/17 9:17
 */
@Component
public class MachUpMsgProcessor0x0A implements MachUpMsgProcessor<MachMsg0x0A> {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private AmqpTemplate amqpTemplate;

    @Override
    public void processMsg(MachMsg0x0A reqMsg) {

        String textMsg = JSONUtil.toString(reqMsg);
        Integer deviceId = reqMsg.getDeviceId();
        logger.info("处理0x0A数据:{}", textMsg);

        //处理报警信息
        try {
            amqpTemplate.convertAndSend(QueueConst.MACH_MSG_0X0A, textMsg);
        } catch (Exception ex) {
            logger.error("", ex);
        }
    }
}
